﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class main : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bd();
        }
    }
    void bd()
    {
        if (Request.Cookies["loginname"] == null)
        {
            Response.Redirect("~/login.aspx");
        }
        string loginname = Server.HtmlEncode(Request.Cookies["loginname"].Value);
        if (loginname != "")
        {
            CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
            CMSModel.User user = dal.User.First(x => x.LoginName.Contains(loginname));
            lblName.Text = user.LoginName;
            lblRoleName.Text = user.Role.RoleName;
            lblTName.Text = user.LoginName;
        }
        else {
            ClientScript.RegisterStartupScript(GetType(), "error", "alert('你还没有登录呢!'),document.location='login.aspx'", true);
        }
    }
}
